import { Component, Input, OnInit } from '@angular/core';
import { ThreadsCollectStatsVo } from 'src/app/model/threads-collect-stats-vo';

@Component({
  selector: 'app-threads-item-embed',
  templateUrl: './threads-item-embed.component.html',
  styles: [``]
})
export class ThreadsItemEmbedComponent implements OnInit {
  @Input('thread')
  public item!: ThreadsCollectStatsVo;
  public threadsStatsIco: string = 'topic_normal';
  public threadsBgColor: string = '';

  constructor() { }

  ngOnInit(): void {
    this.setIco(this.item.threadsVo.status);
    if (this.item.threadsVo.tops) {
      this.threadsBgColor = 'updated-rows';
    }
  }

  private setIco(stats: number): void {
    let tmp: string = 'topic_normal';
    switch (stats) {
      case 1: {
        tmp = 'topic_locked';
        break;
      }
      case 4: {
        tmp = 'topic_normal';
        break;
      }
      default: {
        tmp = 'topic_read';
        break;
      }
    }
    this.threadsStatsIco = tmp;
  }
}
